package com.bizark.rpc.api.share_serv.share.application.service;

import com.bizark.rpc.common.annotation.DataSourceKey;
import com.bizark.rpc.common.dao.DaoClient;
import com.bizark.rpc.common.enm.DataSourceEnum;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by tsj on 2017/3/6.
 */
@Controller
public class OrganizationServiceImpl implements OrganizationService {

    @Autowired
    private DaoClient daoClient;

    @Override
    @DataSourceKey(dataSource = DataSourceEnum.DASHBOARD)
    public Map<String, Object> getOrganizationById(Long id) {
        Map<String, Object> params = new HashedMap();
        params.put("id", String.valueOf(id));
        return getOrganization(params);
    }

    @Override
    @DataSourceKey(dataSource = DataSourceEnum.DASHBOARD)
    public Map<String, Object> getOrganization(Map<String, Object> params) {
        Map<String, Object> map = new HashMap<>();
        map = daoClient.selectMap("com.bizark.organizations.select", params);
        return map;
    }


}
